<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\index\controller;

/**
 * 前端首页控制器
 */
class Index extends IndexBase
{
    
    
    // 首页
    public function index($cid = 0)
    {
        
        $this->sendMessage('index');
        
        $m_where['category_id'] = array('in','10,11,12');
                
        $this->assign("modulle_list",$this->logicArticle->getArticleList($m_where,'*','sort'));
        
        //获取案例列表
        $case_where['is_index'] = 1;
        
        $this->assign('works_list',$this->logicProduct->getProductList3($this->param,$case_where,'*','sort'));
        
        //获取新闻列表
        $n_where['category_id'] = array('in','7,8');
        
        $n_where['is_index'] = 1;
                
        $this->assign("news_list",$this->logicArticle->getIndexNewsList($n_where,'*','sort'));
        
        //获取我们的客户
        $this->assign('cus_list',$this->logicCustomer->getCustomerList([],'id,logo_id,default_logo','sort'));
        
          //获取联系方式
        $this->getContact();
        
        return $this->fetch('index');
    }
    
    /**
     * 关于我们
     */
    public function about($cid = 0)
    {
        $this->sendMessage('about');
        //获取关于我们文章
        $where['a.category_id'] = 2;
        
        $where['a.status'] = 1;
        
        $field = 'a.name,a.describe,a.content,a.content_second,a.content_third,a.content_fourth,a.content_fifth,a.content_sixth,a.content_seven,a.cover_id,a.img_ids,a.status';

        $this->assign('info',$this->logicArticle->getArticleInfo($where,$field));
    
        //获取我们的客户
        $this->assign('list',$this->logicCustomer->getCustomerList([],'id,logo_id,default_logo'));
        
        //获取联系方式
        $this->getContact();
        
        return $this->fetch('about');
    }
    
    /**
     * 业务
     */
    public function business($cid = 0)
    {
        $this->sendMessage('business');
        
        $where['a.category_id'] = array('in','3,4,5,6');
        
        $where['a.status'] = 1;
                
        $field = 'a.name,a.name_en,a.content,a.content_second';   
         
        $list = $this->logicArticle->getArticleList($where,$field);
        
        $this->assign('list',$list);
        
        //获取联系方式
        $this->getContact();
        
        return $this->fetch('business');
    }
    
    /**
     * 案例
     */
    public function works()
    {
        $this->sendMessage('works');
                
        $this->assign('list',$this->logicProduct->getProductList2($this->param,[],'*','sort'));   
       
        //获取联系方式
        $this->getContact();
        
        if(array_key_exists('category_id', $this->param)){
            $category = $this->param['category_id'];
        }else{
            $category = 0;
        }
        
        $this->assign('category',$category);
        
        return $this->fetch('works');
    }
    
    
    /**
     * 新闻资讯
     */
    public function news()
    {
        $this->sendMessage('news');
        
        $this->assign('list',$this->logicArticle->getArticleList2($this->param));
        
        if(array_key_exists('category_id', $this->param)){
            $category = $this->param['category_id'];
        }else{
            $category = 0;
        }
        
        $this->getContact();
         
        $this->assign('category',$category);
        
        return $this->fetch('news');
    }
    

    /**
     * 新闻详情
     */
    public function newsDetail()
    {
        
        $this->assign('info',$this->logicArticle->getArticleDetail($this->param,'name,updated_at,content,cover_id'));
        
        $this->assign('list',$this->logicArticle->getRelatedArticle($this->param));
        
        $this->getContact();
        
        return $this->fetch('news_details');
    }
    
    /**
     * 联系
     */
    public function contact()
    {
        $where['category_id'] = 9;
        
        $field = 'a.name,a.describe,a.content';
        
        $this->getContact();
        
        $this->assign('list',$this->logicArticle->getArticleList($where,$field));
        
        return $this->fetch('contact');
    }
    
    
    /**
     * 发送留言
     */
    public function sendMessage($url)
    {

        IS_POST && $this->jump($this->logicServe->messageEdit($this->param,$url));
    }
    
    
    /**
     * 获取联系方式
     */
    public function getContact()
    {
        $where['status'] = 1;
        
        $this->assign('contact',$this->logicContact->getContactInfo($where));
    }   
  
}
